package cn.lml.lession.auth.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpoint;
import org.springframework.security.oauth2.provider.token.ConsumerTokenServices;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.lml.lession.common.util.Result;

@FrameworkEndpoint
public class RevokeTokenEndpoint {

    @Autowired
    @Qualifier("consumerTokenServices")
    ConsumerTokenServices consumerTokenServices;

    @PostMapping("/oauth/logout")
    @ResponseBody
    public Result revokeToken(String accessToken) {
        if (consumerTokenServices.revokeToken(accessToken)){
            return Result.ok("注销成功");
        }else{
            return Result.error("注销失败");
        }
    }
    
}